import java.util.Vector;

import edu.stanford.nlp.process.Morphology;


public class Stemmer {

	/**
	 * Stems the input word using the Stanford JavaNLP API
	 * 
	 * @param word	Word to be stemmed
	 * @return		The stem of word
	 */
	public static String stem(String word) {
		// Treats the particular case of the word 'bad', which is stemed as 'bid'
		if(word.equals("bad"))
			return "bad";
		else
		{
			Morphology morph = new Morphology();
			return morph.stem(word);
		}
	}

	/**
	 * Stems all the input words inside the Vector words using the Stanford JavaNLP API
	 * 
	 * @param words	Vector of words to be stemed
	 * @return		A Vector with the stem of all input words
	 */
	public static Vector<String> stem(Vector<String> words)
	{
		Morphology morph = new Morphology();
		Vector<String> newVect = new Vector<String>();
		
		for(String word : words)
		{
			// Treats the particular case of the word 'bad', which is stemed as 'bid'
			if(word.equals("bad"))
				newVect.add("bad");
			else
				newVect.add(morph.stem(word));
		}
		
		return newVect;
	}

}
